package com.bwie.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bwie.pojo.TCq;
import com.bwie.pojo.TZc;
import com.bwie.service.TCqService;
import com.bwie.mapper.TCqMapper;
import com.bwie.utils.R;
import com.bwie.vo.PageInfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
* @author 28463
* @description 针对表【t_cq】的数据库操作Service实现
* @createDate 2025-07-03 09:40:22
*/
@Service
@Transactional
public class TCqServiceImpl extends ServiceImpl<TCqMapper, TCq>
    implements TCqService{
    @Autowired
    TCqMapper tCqMapper;


    @Override
    public R getcqlist(PageInfoVo pageInfoVo) {
        Page<TCq> page = new Page<>(pageInfoVo.getPageNum(), pageInfoVo.getPageSize());
        Page<TCq> tCqPage = tCqMapper.selectPage(page, null);
        return R.OK(tCqPage);
    }

    @Override
    public R getMyZc(PageInfoVo pageInfoVo) {
        return null;
    }

    @Override
    public R addcq(TCq tCq) {
        if(tCq.getCzPrice()>tCq.getMyPrice()){
            return R.ERROR(500,"充值金额不能大于余额");
        }

        tCqMapper.insert(tCq);
        return R.OK();
    }


}




